from datetime import date,timedelta
from random import randint


def srhs(namelb):
    dic = {}.fromkeys(namelb)
    for key in dic :
        year = randint(1990,1999)
        month = randint(1, 12)
        day = randint(1,30)
        dic[key]=date(year,month,day)
    return dic
def xjsr(dic):
    xjj = []
    for key in dic:
        if dic[key].month>=6 and dic[key].month<=8 :
            xjj.append(key)
    return  xjj
#2．需求二：最大的比最小的大多少天（20分）
def bdx(dic):
   li = list(dic.values())
   li.sort()
    print("最大的比最小的大{}".format((li[-1]-li[0]).days))

#3．需求三：谁的生日最早，谁的生日最晚
# 谁的生日最早，谁的生日最晚
def max_min(nlist, nbdic):
    print("\n题3：")
    # 初始化最大值
    maxone = nlist[0]
    maxbirth = []
    for key in nbdic:
        if nbdic[maxone].month > nbdic[key].month:
            maxone = key
            maxbirth = nbdic[key]
        elif nbdic[maxone].month == nbdic[key].month and nbdic[maxone].day > nbdic[key].day:
            maxone = key
            maxbirth = nbdic[key]
    print("生日最早的人：{}  生日是{}月{}日".format(maxone, maxbirth.month, maxbirth.day))

    # 初始化最小值
    minone = nlist[0]
    minbirth = []
    for key in nbdic:
        if nbdic[minone].month < nbdic[key].month:
            minone = key
            minbirth = nbdic[key]
        elif nbdic[minone].month == nbdic[key].month and nbdic[minone].day < nbdic[key].day:
            minone = key
            minbirth = nbdic[key]
    print("生日最晚的人：{}  生日是{}月{}日".format(minone, minbirth.month, minbirth.day))

if __name__ == '__main__':
    namelb =  ["赵一","赵二","赵三","赵四","赵武","赵刘","赵起","赵吧","赵就","赵是"]
    dd  = srhs(namelb)
    print(dd)
    xj = xjsr(dd)
    print("夏季出生的有:{}".format(xj))
    bdx(dd)
    shengr(dd)